package com.zy.explore.design.interfaces.facade.v1;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zy.explore.design.patterns.observer.eventbus.EventBusCenter;
import com.zy.explore.design.patterns.observer.eventbus.EventListener;
import com.zy.explore.design.patterns.observer.eventbus.NotifyEvent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description 观察者模式示例Facade
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2021年05月15日 14:27
 */
@Api(tags = {"观察者模式示例Facade"})
@RestController
@RequestMapping("/observer")
public class ObserverFacade {

    @ApiOperationSupport(order = 10, author = "🇨🇳中国印🇨🇳")
    @ApiOperation("调用观察者模式方法")
    @PostMapping("/useObserver")
    public Integer useObserver() {
        EventListener eventListener = new EventListener();
        EventBusCenter.register(eventListener);
        EventBusCenter.post(new NotifyEvent("18054236735", "zyexplorj2ee@sina.com", "66666"));
        return 1;
    }
}
